{extend name="Public:_single" /}
{block name="title"}Banner 编辑{/block}
{block name="description"}描述{/block}
{block name="keywords"}关键词{/block}
{block name="heading"}Banner{/block}
{block name="breadcrumb"}Banner > 编辑{/block}
{block name="wrapper"}

<!-- Plugin stylesheets -->
<link href="/static/plugins/misc/qtip/jquery.qtip.css" rel="stylesheet" type="text/css" />
<link href="/static/plugins/forms/inputlimiter/jquery.inputlimiter.css" type="text/css" rel="stylesheet" />
<link href="/static/plugins/forms/togglebutton/toggle-buttons.css" type="text/css" rel="stylesheet" />
<link href="/static/plugins/forms/uniform/uniform.default.css" type="text/css" rel="stylesheet" />
<link href="/static/plugins/forms/color-picker/color-picker.css" type="text/css" rel="stylesheet" />
<link href="/static/plugins/forms/select/select2.css" type="text/css" rel="stylesheet" />
<link href="/static/plugins/forms/validate/validate.css" type="text/css" rel="stylesheet" />
    <form action="javascript:void(0);" id="form-banner-edit" class="form-horizontal" data-action="{:url('admin/Banner/editProcess')}" data-id="{$data.id}">
        <div class="form-group">
            <label class="col-lg-3 control-label" for="form-position">位置</label>
            <div class="col-lg-9 ">
                <select name="banner_id" class="nostyle form-control" id="form-position" disabled>
                    <option value="0">无导向</option>
                    {volist name="position" id="vo"}
                    <option value="{$vo.id}" {$data.banner.id==$vo.id?'selected':''}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label" >类型</label>
            <div class="col-lg-9">
                <label class="radio-inline" for="form-type_1">
                    <input type="radio" name="type" class="form-control" id="form-type_1" value="1" {$data.type==1?'checked':''}> 导向文章
                </label>
                <label class="radio-inline" for="form-type_2">
                    <input type="radio" name="type" class="form-control" id="form-type_2" value="2" {$data.type==2?'checked':''}> 导向专题
                </label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label" for="form-keywords">keywords</label>
            <div class="col-lg-9">
                <input type="text" name="keywords" class="form-control uniform-input text" id="form-keywords" value="{$data.keywords}">
            </div>
        </div>

        <div class="form-group">
            <div class="col-lg-offset-3 col-lg-9">
                <button type="submit" class="btn btn-info">保存</button>
            </div>
        </div>
        
    </form>
{/block}

{block name="plugins_js"}

<!-- Form plugins -->

<script type="text/javascript" src="/static/plugins/forms/elastic/jquery.elastic.js"></script>
<script type="text/javascript" src="/static/plugins/forms/inputlimiter/jquery.inputlimiter.1.3.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/maskedinput/jquery.maskedinput-1.3.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/togglebutton/jquery.toggle.buttons.js"></script>
<script type="text/javascript" src="/static/plugins/forms/uniform/jquery.uniform.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/globalize/globalize.js"></script>
<script type="text/javascript" src="/static/plugins/forms/color-picker/colorpicker.js"></script>
<script type="text/javascript" src="/static/plugins/forms/timeentry/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/select/select2.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/dualselect/jquery.dualListBox-1.3.min.js"></script>
<script type="text/javascript" src="/static/plugins/forms/tiny_mce/tinymce.min.js"></script>
<script type="text/javascript" src="/static/js/supr-theme/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/static/js/supr-theme/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript" src="/static/plugins/forms/validate/jquery.validate.js"></script>
<script type="text/javascript" src="/static/plugins/forms/wizard/jquery.form.js"></script>

<!-- Init plugins -->

<script type="text/javascript" src="/static/js/forms.js"></script><!-- Init plugins only for page -->

<script>
    $("#form-banner-edit").validate({
        rules:{
            banner_id: {
                required: true,
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $(form).ajaxSubmit({
                type:'post',
                url: $("#form-banner-edit").data('action'),
                dataType: 'json',
                data:{
                    id:$("#form-banner-edit").data('id')
                },
                success:function(response){
                    if (response.status == 'success') {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg('编辑成功',{icon:1,time:10000});
                        setTimeout(function(){
                            parent.location.reload(); // 刷新页面
                            parent.layer.close(index);
                        },1200);
                    } else if ( response.status == 'failed') {
                        parent.layer.msg('编辑失败，code='+response.code,{icon:2,time:1000});
                    }
                },error:function(data) {
                    parent.layer.msg('无效的请求',{icon:2,time:1000});
                }
            });
        }
    });
</script>
{/block}

